﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBConnection;

namespace ChatApp
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {


        }

        protected void CreateUser(object sender, EventArgs e)
        {
            DBConnection.TwitterDataContext db = new DBConnection.TwitterDataContext();

            string userID = UserIDRegisterTextBox.Text;
            string userPwd = UserPasswordRegisterTextBox.Text;

            if (DBConnection.UsersDAO.RegisterUser(userID, userPwd, db))
            {
                Session["userID"] = UserIDRegisterTextBox.Text;
                Response.Redirect("Chat.aspx");
            }
            else
            {
                RegisterResultLabel.Text = "Invalid user/password! The user requested maybe exist.";
            }
        }
    }
}